package com.rmy.queue.service.impl;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.rmy.CompUtils;
import com.rmy.common.annotation.DataScope;
import com.rmy.common.core.lang.IdGenerator;
import com.rmy.common.core.text.Convert;
import com.rmy.common.utils.DateUtils;
import com.rmy.common.utils.SecurityUtils;
import com.rmy.domain.CompArea;
import com.rmy.framework.manager.AsyncManager;
import com.rmy.queue.common.ErrorTipsConst;
import com.rmy.queue.common.QueueConst;
import com.rmy.queue.common.factory.DeviceAsyncFactory;
import com.rmy.queue.common.webSocket.CompShowWebSocketServer;
import com.rmy.queue.common.webSocket.ProjectWebSocketServer;
import com.rmy.queue.domain.*;
import com.rmy.queue.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.rmy.queue.mapper.QmsMainBusinessMapper;
import org.springframework.util.Assert;

import static com.rmy.common.utils.PageUtils.startPage;

/**
 * 预约管理Service业务层处理
 *
 * @author rmy
 * @date 2022-09-29
 */
@Service
public class QmsMainBusinessServiceImpl implements IQmsMainBusinessService {
    @Autowired
    private QmsMainBusinessMapper qmsMainBusinessMapper;

    @Autowired
    private IQmsErpRuleService qmsErpRuleService;

    @Autowired
    private IQmsBusinessConfigService qmsBusinessConfigService;

    @Autowired
    private IQmsQueueListService qmsQueueListService;

    @Autowired
    private IQmsWindowInfoService qmsWindowInfoService;

    @Autowired
    private IQmsCompConfigService qmsCompConfigService;

    @Autowired
    private IQmsBerrConfigService qmsBerrConfigService;

    @Autowired
    private IQmsWindowBusinessService qmsWindowBusinessService;

    @Autowired
    private IQmsVoicConfigService qmsVoicConfigService;

    @Autowired
    IdGenerator idGenerator;

    /**
     * 查询预约管理
     *
     * @param mbSerialNo 预约管理主键
     * @return 预约管理
     */
    @Override
    public QmsMainBusiness selectQmsMainBusinessByMbSerialNo(String mbSerialNo) {
        return qmsMainBusinessMapper.selectQmsMainBusinessByMbSerialNo(mbSerialNo);
    }

    /**
     * 查询预约管理列表
     *
     * @param qmsMainBusiness 预约管理
     * @return 预约管理
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<QmsMainBusiness> selectQmsMainBusinessList(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectQmsMainBusinessList(qmsMainBusiness);
    }

    /**
     * 新增预约管理
     *
     * @param qmsMainBusiness 预约管理
     * @return 结果
     */
    @Override
    public int insertQmsMainBusiness(QmsMainBusiness qmsMainBusiness) {
        qmsMainBusiness.setMbSerialNo(idGenerator.nextIdStr());
        qmsMainBusiness.setCreateTime(DateUtils.getNowDate());
        return qmsMainBusinessMapper.insertQmsMainBusiness(qmsMainBusiness);
    }

    /**
     * 修改预约管理
     *
     * @param qmsMainBusiness 预约管理
     * @return 结果
     */
    @Override
    public int updateQmsMainBusiness(QmsMainBusiness qmsMainBusiness) {
        qmsMainBusiness.setUpdateTime(DateUtils.getNowDate());
        return qmsMainBusinessMapper.updateQmsMainBusiness(qmsMainBusiness);
    }

    /**
     * 批量删除预约管理
     *
     * @param mbSerialNos 需要删除的预约管理主键
     * @return 结果
     */
    @Override
    public int deleteQmsMainBusinessByMbSerialNos(String[] mbSerialNos) {
        return qmsMainBusinessMapper.deleteQmsMainBusinessByMbSerialNos(mbSerialNos);
    }

    /**
     * 删除预约管理信息
     *
     * @param mbSerialNo 预约管理主键
     * @return 结果
     */
    @Override
    public int deleteQmsMainBusinessByMbSerialNo(String mbSerialNo) {
        return qmsMainBusinessMapper.deleteQmsMainBusinessByMbSerialNo(mbSerialNo);
    }

    @Override
    public int takeNumber(QmsMainBusiness qmsMainBusiness) {
        // 1. 查询业务type关联的业务ID
        int nRet = -1;
        QmsErpRule qmsErpRule = new QmsErpRule();
        qmsErpRule.setErpBusinessType(qmsMainBusiness.getBusinessType());
        List<QmsErpRule> qmsErpRuleList = qmsErpRuleService.selectQmsErpRuleList(qmsErpRule);
        if (qmsErpRuleList != null && qmsErpRuleList.size() > 0) {
            // 2. 根据业务ID查询业务配置
            QmsBusinessConfig qmsBusinessConfig = qmsBusinessConfigService.selectQmsBusinessConfigById(qmsErpRuleList.get(0).getBusinessId());
            QmsQueueList qmsQueueList = new QmsQueueList();
            qmsQueueList.setBusinessId(qmsBusinessConfig.getId());
            qmsQueueList.setOrgNo(qmsMainBusiness.getOrgNo());
            // 设置身份证号码及证件类型
            qmsQueueList.setCertType("1");
            qmsQueueList.setCardNo(qmsMainBusiness.getDriverIdNo());
            if (qmsQueueListService.genQueueNumber(qmsQueueList) > 0) {
                // 3. 更新主表对应的叫号ID字段和流程状态（已取号）
                qmsMainBusiness.setSerialNo(qmsQueueList.getSerialNo());
                qmsMainBusiness.setFlowStatus(QueueConst.FLOW_STATUS.已签到);
                nRet = qmsMainBusinessMapper.updateQmsMainBusiness(qmsMainBusiness);
            }
        } else {
            nRet = -2;
        }
        return nRet;
    }

    @Override
//    @DataScope(deptAlias = "d")
    public List<QmsMainBusiness> selectBusinessQueueList(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectBusinessQueueList(qmsMainBusiness);
    }

    @Override
    public List<QmsMainBusiness> selectBusinessQueueListTaked(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectBusinessQueueListTaked(qmsMainBusiness);
    }

    @Override
    public List<QmsMainBusiness> selectBusinessQueueListCalled(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectBusinessQueueListCalled(qmsMainBusiness);
    }

    @Override
    public List<QmsMainBusiness> selectQueueListByUUID(QmsMainBusiness qmsMainBusiness) throws Exception {
        // 1. 根据uuid查鹤位信息
        QmsWindowInfo qmsWindowInfo = qmsWindowInfoService.selectQmsWindowInfoByUUID(qmsMainBusiness.getWindowUuid());
        Assert.notNull(qmsWindowInfo, ErrorTipsConst.TIPS_WINDOW_NOT_FOUND);

        // 2. 根据鹤位信息查询绑定的业务配置信息
        QmsWindowBusiness tmpWinBusiness = new QmsWindowBusiness();
        tmpWinBusiness.setWindowId(qmsWindowInfo.getId());
        List<QmsWindowBusiness> qmsWindowBusinessList = qmsWindowBusinessService.selectQmsWindowBusinessList(tmpWinBusiness);

        List<String> listErpBusinessType = new ArrayList<>();
        // 3. 根据业务信息ERP业务配置
        for (QmsWindowBusiness tmpWinB : qmsWindowBusinessList) {
            QmsErpRule tmpErpRule = new QmsErpRule();
            tmpErpRule.setBusinessId(tmpWinB.getBusinessId());
            List<QmsErpRule> resErpRuleList = qmsErpRuleService.selectQmsErpRuleList(tmpErpRule);
            for (QmsErpRule resErpRule : resErpRuleList) {
                listErpBusinessType.add(resErpRule.getErpBusinessType());
            }
        }
        // 4. 根据ERP业务查询当天队列

        qmsMainBusiness.setBusinessTypes(listErpBusinessType.toArray(new String[]{}));
        qmsMainBusiness.setOrgNo(Convert.toStr(SecurityUtils.getDeptId()));
        qmsMainBusiness.setWindowUuid(qmsWindowInfo.getUuid());
        startPage();
        return this.selectBusinessQueueList(qmsMainBusiness);
    }


    public void sendCompScreen(String orgNo) throws IOException {
        QmsCompConfig qmsCompConfig = new QmsCompConfig();
        qmsCompConfig.setOrgNo(orgNo);
        List<QmsCompConfig> compConfigs = qmsCompConfigService.selectQmsCompConfigList(qmsCompConfig);
        List<QmsQueueList> waitQueueList = new ArrayList<>();
        List<QmsMainCalledResp> qmsMainCalledRespList = new ArrayList<>();
        if (compConfigs.size() > 0) {
            // 查询等待队列信息
            waitQueueList = qmsQueueListService.selectQueueListByOrgNo(orgNo);
            // 查询已叫号信息
            qmsMainCalledRespList = this.selectMainCalledListByOrgNo(orgNo);
        }
        for (QmsCompConfig compConfig : compConfigs) {
            if ("1".equals(compConfig.getCompType())) {
                String strContent = Convert.toStr(compConfig.getContentTemplate(), "");
                int z = 1;
                for (QmsMainCalledResp qmsMainCalledResp : qmsMainCalledRespList) {
                    strContent = strContent.replace("{queueNo" + z + "}", qmsMainCalledResp.getQueueNo());
                    strContent = strContent.replace("{carNo" + z + "}", qmsMainCalledResp.getCarNo());
                    strContent = strContent.replace("{windowName" + z + "}", qmsMainCalledResp.getWindowName());
                    z++;
                }

                int i = 1;
                for (QmsQueueList queue : waitQueueList) {
                    strContent = strContent.replace("{waitNo" + i + "}", queue.getQueueNo());
                    i++;
                }

                List<CompArea> compNewList = new ArrayList<>();
                List<CompArea> compAreaList = CompUtils.parseContent(strContent);
                // 清空没有填充的数据
                for (CompArea compArea : compAreaList) {
                    boolean bContain = false;
                    for (int w = 1; w < 50; w++) {
                        if (compArea.getContent().contains("{queueNo" + w + "}") ||
                            compArea.getContent().contains("{carNo" + w + "}") ||
                            compArea.getContent().contains("{windowName" + w + "}") ||
                            compArea.getContent().contains("{waitNo" + w + "}")) {
                            bContain = true;
                            break;
                        }
                    }
                    if (!bContain) {
                        compNewList.add(compArea);
                    }
                }
                strContent = "{\"areas\":"+JSON.toJSONString(compNewList)+"}";

                // 异步处理
                AsyncManager.me().execute(
                        DeviceAsyncFactory.sendComp(compConfig.getDeviceIp(),
                                compConfig.getDevicePort().intValue(),
                                compConfig.getJsonSettings(), strContent));
            } else {
                // 电视屏推送 通过websocket
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("cmd", QueueConst.WEBSOCKET_CMD.CMD_CALL_NUMBER_NOTICE);
                CompShowWebSocketServer.sendMessage(compConfig.getOrgNo(), jsonObject.toString());
            }
        }
    }


    private void sendVoicSound(String orgNo, String cmd, Map<String, Object> mapParams) {
        qmsVoicConfigService.sendVoicByCmd(orgNo, cmd, mapParams);
    }


    private void sendBerrScreen(String orgNo, Long windowId, Map<String, Object> mapParams) throws IOException {
        qmsBerrConfigService.sendBerr(orgNo, windowId, mapParams);
    }


    @Override
    public QmsMainBusiness callBusinessNumber(String windowUuid) throws Exception {
        Map<String, Object> mapParams = new HashMap<>();

        QmsWindowInfo qmsWindowInfo = qmsWindowInfoService.checkWindowExistByUuid(windowUuid);
        QmsQueueList qmsQueueList = new QmsQueueList();
        qmsQueueList.setCallerId(SecurityUtils.getUsername());
        qmsQueueList.setOrgNo(Convert.toStr(SecurityUtils.getDeptId()));
        qmsQueueList.setWindowId(qmsWindowInfo.getId());

        QmsQueueList resQueueList = qmsQueueListService.callQueueNoByBusiness(qmsQueueList);
        Assert.notNull(resQueueList, ErrorTipsConst.TIPS_NO_QUEUE);
        mapParams.put("{queueNo}", resQueueList.getQueueNo());
        mapParams.put("{windowName}", qmsWindowInfo.getWindowName());

        QmsMainBusiness tmpSelect = new QmsMainBusiness();
        tmpSelect.setSerialNo(resQueueList.getSerialNo());
        List<QmsMainBusiness> qmsMainBusinessList = this.selectQmsMainBusinessList(tmpSelect);
        Assert.notEmpty(qmsMainBusinessList, ErrorTipsConst.TIPS_BUSINESS_NOT_FOUND);

        QmsMainBusiness qmsMainBusiness = qmsMainBusinessList.get(0);
        mapParams.put("{carNo}", qmsMainBusiness.getCarNo());
        // 已叫号
        qmsMainBusiness.setFlowStatus(QueueConst.FLOW_STATUS.已叫号);
        this.updateQmsMainBusiness(qmsMainBusiness);
        // 查找机构下所有的窗口UUID
        String targetWindowUuids = "";
        QmsWindowInfo orgSelect = new QmsWindowInfo();
        orgSelect.setOrgNo(qmsWindowInfo.getOrgNo());
        List<QmsWindowInfo> qmsWindowInfoList = qmsWindowInfoService.selectQmsWindowInfoList(orgSelect);
        for (int y = 0; y < qmsWindowInfoList.size(); y++){
            targetWindowUuids += qmsWindowInfoList.get(y).getUuid() +",";
        }
        if(targetWindowUuids.length() > 0){
            targetWindowUuids = targetWindowUuids.substring(0,targetWindowUuids.length() -1);
        }
        // websocket推送给其他柜员
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("cmd", QueueConst.WEBSOCKET_CMD.CMD_TAKE_NUMBER_NOTICE);
        ProjectWebSocketServer.sendTargetMessage(targetWindowUuids, jsonObject.toString());

        // 异步 发语音
        sendVoicSound(qmsMainBusiness.getOrgNo(), QueueConst.VoicCmd.CMD_CALL_NO, mapParams);

        // 根据机构查询综合屏
        sendCompScreen(qmsMainBusiness.getOrgNo());

        // 异步 发条屏
        sendBerrScreen(qmsMainBusiness.getOrgNo(), qmsWindowInfo.getId(), mapParams);

        return qmsMainBusiness;
    }

    @Override
    public QmsMainBusiness recallBusinessNumber(String windowUuid) throws Exception {
        Map<String, Object> mapParams = new HashMap<>();
        // 1. 校验窗口及查询窗口信息
        QmsWindowInfo qmsWindowInfo = qmsWindowInfoService.checkWindowExistByUuid(windowUuid);

        QmsQueueList qmsQueueList = new QmsQueueList();
        qmsQueueList.setCallerId(SecurityUtils.getUsername());
        qmsQueueList.setOrgNo(Convert.toStr(SecurityUtils.getDeptId()));
        qmsQueueList.setWindowId(qmsWindowInfo.getId());
        // 2. 查询正在叫号排队信息
        QmsQueueList resQueue = qmsQueueListService.selectAvaliableReCall(qmsQueueList);
        Assert.notNull(resQueue, ErrorTipsConst.TIPS_NO_CALLING_INFO);
        mapParams.put("{queueNo}", resQueue.getQueueNo());
        mapParams.put("{windowName}", qmsWindowInfo.getWindowName());
        QmsMainBusiness tmpSelect = new QmsMainBusiness();
        tmpSelect.setSerialNo(resQueue.getSerialNo());
        List<QmsMainBusiness> qmsMainBusinessList = this.selectQmsMainBusinessList(tmpSelect);
        Assert.notEmpty(qmsMainBusinessList, ErrorTipsConst.TIPS_BUSINESS_NOT_FOUND);
        QmsMainBusiness qmsMainBusiness = qmsMainBusinessList.get(0);
        mapParams.put("{carNo}", qmsMainBusiness.getCarNo());
        // 发送语音 （重呼只需要再次发语音即可）
        // 异步 发语音
        sendVoicSound(qmsMainBusiness.getOrgNo(), QueueConst.VoicCmd.CMD_CALL_NO, mapParams);

        return qmsMainBusiness;
    }

    @Override
    public QmsMainBusiness ignoreBusinessNumber(String windowUuid) throws Exception {
        QmsQueueList resQueue = qmsQueueListService.ignoreCurrentNumberByUuid(windowUuid);
        QmsMainBusiness tmpSelect = new QmsMainBusiness();
        tmpSelect.setSerialNo(resQueue.getSerialNo());
        List<QmsMainBusiness> qmsMainBusinessList = this.selectQmsMainBusinessList(tmpSelect);
        Assert.notEmpty(qmsMainBusinessList, ErrorTipsConst.TIPS_BUSINESS_NOT_FOUND);
        QmsMainBusiness qmsMainBusiness = qmsMainBusinessList.get(0);
        // 已跳过
        qmsMainBusiness.setFlowStatus(QueueConst.FLOW_STATUS.已忽略);
        this.updateQmsMainBusiness(qmsMainBusiness);
        return qmsMainBusiness;
    }

    @Override
    public QmsMainBusiness callByQueueNumber(String windowUuid, String queueNo) throws Exception {
        Map<String, Object> mapParams = new HashMap<>();
        QmsWindowInfo qmsWindowInfo = qmsWindowInfoService.checkWindowExistByUuid(windowUuid);

        // 将上次的排队信息更新结束
        int nRet = qmsQueueListService.updateQueueCompleteByWindowId(qmsWindowInfo.getId());
        Assert.isTrue(nRet>0, ErrorTipsConst.TIPS_SET_QUEUE_OVER_ERROR);

        QmsQueueList qmsQueueList = new QmsQueueList();
        qmsQueueList.setOrgNo(Convert.toStr(SecurityUtils.getDeptId()));
        qmsQueueList.setQueueNo(queueNo);
        qmsQueueList.setWindowId(qmsWindowInfo.getId());
        QmsQueueList resQueue = qmsQueueListService.selectQmsQueueByQueueNo(qmsQueueList);
        Assert.notNull(resQueue, ErrorTipsConst.TIPS_QUEUE_NO_NOT_FOUND);
        mapParams.put("{queueNo}", resQueue.getQueueNo());
        mapParams.put("{windowName}", qmsWindowInfo.getWindowName());

        resQueue.setCallerId(SecurityUtils.getUsername());
        resQueue.setCallTime(DateUtils.getNowDate());
        resQueue.setStatus(QueueConst.QUEUE_STATUS.CALL_NUMBER);
        resQueue.setWindowId(qmsWindowInfo.getId());
        qmsQueueListService.updateQmsQueueList(resQueue);

        QmsMainBusiness tmpSelect = new QmsMainBusiness();
        tmpSelect.setSerialNo(resQueue.getSerialNo());
        List<QmsMainBusiness> qmsMainBusinessList = this.selectQmsMainBusinessList(tmpSelect);
        Assert.notEmpty(qmsMainBusinessList, ErrorTipsConst.TIPS_BUSINESS_NOT_FOUND);

        QmsMainBusiness qmsMainBusiness = qmsMainBusinessList.get(0);
        // 已叫号
        qmsMainBusiness.setFlowStatus(QueueConst.FLOW_STATUS.已叫号);
        this.updateQmsMainBusiness(qmsMainBusiness);

        mapParams.put("{carNo}", qmsMainBusiness.getCarNo());

        // 异步 发语音 发条屏  发综合屏

        // 异步 发语音
        sendVoicSound(qmsMainBusiness.getOrgNo(), QueueConst.VoicCmd.CMD_CALL_NO, mapParams);

        // 根据机构查询综合屏
        sendCompScreen(qmsMainBusiness.getOrgNo());

        // 异步 发条屏
        sendBerrScreen(qmsMainBusiness.getOrgNo(), qmsWindowInfo.getId(), mapParams);


        return qmsMainBusiness;
    }

    @Override
    public String selectBookingCount(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectBookingCount(qmsMainBusiness);
    }

    @Override
    public List<Map<String, Object>> selectWeekBookingCount(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectWeekBookingCount(qmsMainBusiness);
    }

    @Override
    public List<Map<String, Object>> selectWeekTakeNoCount(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectWeekTakeNoCount(qmsMainBusiness);
    }

    @Override
    public List<Map<String, Object>> selectWeekEntryCount(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectWeekEntryCount(qmsMainBusiness);
    }

    @Override
    public List<Map<String, Object>> selectWeekExitCount(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectWeekExitCount(qmsMainBusiness);
    }

    @Override
    public String selectTakeNoCount(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectTakeNoCount(qmsMainBusiness);
    }

    @Override
    public String selectWaitingCallCount(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectWaitingCallCount(qmsMainBusiness);
    }

    @Override
    public String selectCallingCount(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectCallingCount(qmsMainBusiness);
    }

    @Override
    public String selectEntryCount(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectEntryCount(qmsMainBusiness);
    }

    @Override
    public String selectExitCount(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectExitCount(qmsMainBusiness);
    }

    @Override
    public List<QmsMainCalledResp> selectMainCalledListByOrgNo(String orgNo) {

        return qmsMainBusinessMapper.selectMainCalledListByOrgNo(orgNo);
    }

    @Override
    public List<QmsMainCalledResp> selectMainWaitCallByOrgNo(String orgNo) {
        return qmsMainBusinessMapper.selectMainWaitCallByOrgNo(orgNo);
    }

    @Override
    public QmsMainBusiness selectCurCallQueueNo(String windowUuid) {
        QmsMainBusiness qmsMainBusiness = new QmsMainBusiness();
        QmsWindowInfo qmsWindowInfo = qmsWindowInfoService.selectQmsWindowInfoByUUID(windowUuid);

        QmsQueueList qmsQueueList = new QmsQueueList();
        qmsQueueList.setCallerId(SecurityUtils.getUsername());
        qmsQueueList.setOrgNo(Convert.toStr(SecurityUtils.getDeptId()));
        qmsQueueList.setWindowId(qmsWindowInfo.getId());

        QmsQueueList resQueue = qmsQueueListService.selectAvaliableReCall(qmsQueueList);
        if (resQueue != null) {
            QmsMainBusiness tmpSelect = new QmsMainBusiness();
            tmpSelect.setSerialNo(resQueue.getSerialNo());
            List<QmsMainBusiness> qmsMainBusinessList = this.selectQmsMainBusinessList(tmpSelect);
            if (null != qmsMainBusinessList && qmsMainBusinessList.size() > 0) {
                qmsMainBusiness = qmsMainBusinessList.get(0);
            }
        }
        return qmsMainBusiness;
    }

    @Override
    public List<Map<String, Object>> selectBookingBusinessCount(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectBookingBusinessCount(qmsMainBusiness);
    }

    @Override
    public List<QmsReportSummary> selectSummaryList(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectSummaryList(qmsMainBusiness);
    }

    @Override
    public List<QmsReportSummary> selectSummaryListByDept(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectSummaryListByDept(qmsMainBusiness);
    }

    @Override
    public List<QmsReportSummary> selectSummaryListByBusiness(QmsMainBusiness qmsMainBusiness) {
        return qmsMainBusinessMapper.selectSummaryListByBusiness(qmsMainBusiness);
    }

    @Override
    public List<QmsWindowInfo> selectWindowListByDept(String orgNo) {
        return qmsMainBusinessMapper.selectWindowListByDept(orgNo);
    }


}
